<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册欢迎页</title>
    <script src="/static/js/jquery.js"></script>
    <script>

        $(function () {

            var username = $('#username')
            var phonno = $('#phoneNo')
            var pwd = $('#pwd')
            var nick = $('#nick')

            $('#btn').click(function () {
                // 获取用户提交的注册信息

                let data = {
                    'userName': username.val(),
                    'phoneNo': phonno.val(),
                    'password': pwd.val(),
                    'nick': nick.val()
                }

                if (username.val().length == 0 || phonno.val().length == 0 || pwd.val().length >= 12 || nick.val().length == 0) {
                    alert('请输入正确的注册信息')
                    return
                }

                $.ajax({
                    'url': '/app/regist/registAction/',
                    'type': 'POST',
                    'dataType': 'json',
                    'data': data,
                }).done(function (data) {
                    if (data["regist"] == "0") {
                        alert('注册失败')
                        location.href='/app/login/loginPage/'

                    } else if (data["regist"] == '1') {
                        alert('注册成功')
                        location.href='app/login/index/'
                        0
                    }
                })

            })
        })
    </script>
</head>
<body>

<h1 id="h1">欢迎注册!</h1>

<div>
    用户名:<input type="text" value="" id="username"> <br>
    手机号: <input type="text" value="" id="phoneNo"> <br>
    密码:<input type="password" id="pwd"> <br>
    昵称:<input type="text" id="nick"> <br>
    <br>
    <button id="btn">注册</button>
</div>

</body>
</html>